﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Bamuca.Master" AutoEventWireup="true" CodeBehind="/CadastrarRotinas.aspx.cs" Inherits="Bamuca.CadastrarRotinas" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>.:Bem-Vindo:.</title>
    
    <link href="Styles/StyleModal.css" rel="stylesheet" type="text/css" />
    <style type="text/css">
        .style3
        {
            width: 167px;
            margin-left: 40px;
        }
        .style4
        {
            width: 141px;
            margin-left: 40px;
        }
        .style5
        {
            width: 72%;
        }
        .style6
        {
            width: 180px;
        }
    </style>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

    <div id="datasources" style="display:none;">
        <asp:SqlDataSource ID="SqlDataSourceDropRotina" runat="server" ConnectionString="<%$ ConnectionStrings:BamucaConnectionString1 %>" SelectCommand="SELECT * FROM [Rotinas]">
        </asp:SqlDataSource>
    </div>

    <div id="scriptmanager" style="display:none;">
        <asp:ScriptManager ID="ScriptManager1" runat="server">
        </asp:ScriptManager>
    </div>

    <div id="geral">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <br />
    <div id="listar" align="left">
        <asp:Panel ID="panelLista" runat="server" Visible="true" BorderColor="gray" 
            BorderWidth="1px" Width="414px" Height="379px" BackColor="White">
        
        <h2 align="center">Opções de Rotinas</h2>
        <hr style="width: 490px; height: -12px;" />        
        <table style="width: 411px">
            <tr>
                <td align="left" class="style3" colspan="3">
                    <strong>Selecione a rotina:</strong>
                </td>
            </tr>
            <tr>
                <td align="left" class="style3">
                    <asp:DropDownList ID="dropRotinas" runat="server" AutoPostBack="True" 
                        DataSourceID="SqlDataSourceDropRotina" DataTextField="Nome" 
                        DataValueField="IdRotina" 
                        onselectedindexchanged="dropRotinas_SelectedIndexChanged" 
                        onload="dropRotinas_Load" Width="160px">
                    </asp:DropDownList>
                </td>
                <td align="left" class="style4">
                    <asp:ImageButton ID="imgBtAdd" runat="server" Height="23px" 
                        ImageUrl="~/Imagens/btn_add.png" onclick="imgBtAdd_Click" 
                        ToolTip="Adicionar nova rotina." Width="23px" />
                    &nbsp;<asp:ImageButton ID="imgBtRename" runat="server" Height="23px" 
                        ImageUrl="~/Imagens/btn_renomear.png" onclick="imgBtRename_Click" 
                        ToolTip="Renomear rotina existente" />
                    &nbsp;<asp:ImageButton ID="imgBtDelete" runat="server" Height="23px" 
                        ImageUrl="~/Imagens/btn_delete.png" onclick="imgBtDelete_Click" 
                        ToolTip="Excluir rotina selecionada." Width="23px" />
                    <asp:ConfirmButtonExtender ID="ConfirmButtonExtender2" runat="server" 
                        ConfirmText="Deseja realmente excluir essa rotina?" Enabled="True" 
                        TargetControlID="imgBtDelete">
                    </asp:ConfirmButtonExtender>
                    &nbsp;</td>
                <td align="left" class="style3">
                    <asp:ImageButton ID="ibtnAjuda" runat="server" Height="20px" 
                        ImageUrl="~/Imagens/btn_ajuda.png" ToolTip="Saber mais..." Width="20px" />
                </td>
            </tr>
            <tr>
                <td align="left" class="style3" colspan="3">
                    &nbsp;&nbsp;</td>
            </tr>
            <tr>
                <td class="style3" colspan="3">
                    &nbsp;</td>
            </tr>
            <tr>
                <td class="style3" colspan="3">
                    <asp:GridView ID="gridAcoes" runat="server" AutoGenerateColumns="False" BorderColor="#006699" BorderStyle="Solid" BorderWidth="1px" CellPadding="2" CellSpacing="2" GridLines="None" onrowdatabound="gridAcoes_RowDataBound" ToolTip="Ações designadas a cada rotina.">
                        <Columns>
                            <asp:TemplateField HeaderText="Ativo">
                                <ItemTemplate>
                                    <asp:CheckBox ID="ckbAtivo" runat="server" />
                                </ItemTemplate>
                            </asp:TemplateField>
                            <asp:BoundField DataField="ativo">
                            <ItemStyle Font-Size="0pt" ForeColor="White" Width="1px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="idAcao">
                            <HeaderStyle Font-Size="0pt" Width="1px" />
                            <ItemStyle Font-Size="0pt" ForeColor="White" Width="1px" />
                            </asp:BoundField>
                            <asp:BoundField DataField="nomeAcao" HeaderText="Ação" />
                        </Columns>
                    </asp:GridView>
                </td>
            </tr>
            <tr>
                <td align="left" class="style3" colspan="3">
                    &nbsp;</td>
            </tr>
            <tr>
                <td align="left" class="style3" colspan="3">
                    <asp:ImageButton ID="imgBtSalvarAcoes" runat="server" 
                        Height="30px" ImageUrl="~/Imagens/btn_salvar.png" 
                        onclick="imgBtSalvarAcoes_Click" Visible="False" Width="80px" 
                        ToolTip="Salvar a rotina" />
                </td>
            </tr>
        </table>
        <br />
      </asp:Panel>
      </div>
      

            <asp:ModalPopupExtender ID="ModalCadastro" runat="server" TargetControlID="imgBtAdd" PopupControlID="pnAddRotina" CancelControlID="ibtnCancelar" BackgroundCssClass="modalPopupFundo">
            </asp:ModalPopupExtender>

            <asp:ModalPopupExtender ID="ModalAlteraCadastro" runat="server" TargetControlID="imgBtRename" PopupControlID="pnAddRotina" CancelControlID="ibtnCancelar" BackgroundCssClass="modalPopupFundo">
            </asp:ModalPopupExtender>

            <asp:Panel ID="pnAddRotina" runat="server" BorderWidth="1px" Height="290px" BackColor="White" Width="450px" BorderColor="Gray" CssClass="modalPopup">
            <div style="padding:5px;">
                <h2 align="center">Cadastro de Rotinas</h2>
                <hr align="center" style="width: 442px" />        
                <br />
                <table class="style5">
                    <tr>
                        <td align="left" class="style6">
                            <strong>Nome da rotina:</strong></td>
                        <td>
                            <strong>
                            <asp:TextBox ID="txtCodRotina" runat="server" Visible="False"></asp:TextBox>
                            </strong>
                        </td>
                    </tr>
                    <tr>
                        <td align="left" class="style6">
                            <asp:TextBox ID="tboxNomeRotina" runat="server" Width="170px"></asp:TextBox>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td align="left" class="style6">
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                ControlToValidate="tboxNomeRotina" CssClass="validation" Display="Dynamic" 
                                ErrorMessage="*"></asp:RequiredFieldValidator>
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                    <tr>
                        <td align="left" class="style6">
                            <asp:ImageButton ID="imgBtSalvarRotina" runat="server" Height="30px" 
                                ImageUrl="~/Imagens/btn_salvar.png" onclick="imgBtSalvarRotina_Click" 
                                ToolTip="Salva a nova rotina e retorna" Width="80px" />
                            &nbsp;<asp:ImageButton ID="ibtnCancelar" runat="server" CausesValidation="False" 
                                Height="30px" ImageUrl="~/Imagens/btn_cancelar.png" 
                                onclick="imgbtn_cancelar_Click" ToolTip="Cancela a operação e retorna" 
                                Width="80px" />
                        </td>
                        <td>
                            &nbsp;</td>
                    </tr>
                </table>

                <br />
                <asp:ConfirmButtonExtender ID="imgBtSalvarRotina_ConfirmButtonExtender" runat="server" ConfirmText="Deseja salvar esta rotina?!" Enabled="True" TargetControlID="imgBtSalvarRotina">
                </asp:ConfirmButtonExtender>                
                         
                <asp:SqlDataSource ID="dtsGridAcoes" runat="server"></asp:SqlDataSource>
        </asp:Panel>
    
    </ContentTemplate>
    </asp:UpdatePanel>
    </div>
</asp:Content>
